home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE4 / POWERBASE / DOCS / Ch07-Index < prev    next >
Text File  |  2001-01-27  |  5KB  |  90 lines

  1. ==========================
  2. Ch 7 − Using extra indices
  3. ========================== 
  4.  
  5. The record data is stored in a file called Database inside the database’s
  6. application directory. The order of records within Database is determined by
  7. the order in which the records are entered. To access the records in a
  8. logical order we need one or more indices. Powerbase does have sorting
  9. facilities for sorting reports and  validation tables, but data ordering is
  10. achieved mainly by the use of indices. 
  11.  
  12. The most important index is index 0. This is always called “PrimaryKey” and
  13. is created as part of the process of setting up a database (see 4.5). You
  14. will find the file PrimaryKey inside the database directory. Other,
  15. subsidiary, indices are stored in the database’s Indices directory and all
  16. have a large I on their icon. When a database is opened any indices in this
  17. directory will be loaded automatically. (Indices operate in memory − to
  18. achieve maximum speed − not from disc.) Changes to the database update the
  19. indices and closing the database (or quitting Powerbase itself) causes the
  20. updated indices to be written back to the disc. 
  21.  
  22. Note that the more indices you use the longer it takes to add and delete
  23. records or to make alterations to records which involve changing indices.
  24. The ideal situation might seem to be to have all fields indexed and, given a
  25. fast enough machine, a hard disc and a record structure with not very many
  26. fields, this might be feasible. Remember that fields which are repetitive
  27. (those which have only a few distinct values repeated throughout many
  28. records) do not index efficiently.
  29.  
  30. Subsidiary indices can speed up report printing in some cases (see 3.12). 
  31. When you enter a query Powerbase will see if a subsidiary index can be used
  32. with advantage and, if so, will go ahead and use it.  To indicate that this
  33. is happening the number of the subsidiary index will appear in the small
  34. rectangle at the the top right of the query panel. For the speed-up to work
  35. the case button on the query panel must match the case-dependence of the
  36. index. This is a point easily overlooked!
  37.  
  38. 7.1     Indexing a field
  39. ------------------------
  40. Click MENU over the required field and choose Create Index (Ctrl J) from the
  41. Field submenu. The Key structure window will appear with the tag of the
  42. field you clicked on in the first of the four Field icons. You may use the
  43. bump icons or pop-up menus to bring the tags of the other fields into view
  44. if you wish to base the index on more than one field. Enter the data in
  45. exactly the same way as when creating the primary key index (see 4.5) and
  46. click on Create. If the field is already indexed you will be warned of this
  47. and asked if you wish to overwrite the existing index. When indexing is
  48. complete you will see that the descriptor of the indexed field has changed
  49. from black to dark blue. 
  50.  
  51. If you click the “key” buttons on the keypad (Shift F4 and Shift F5) the red
  52. highlighting of the descriptor which indicates the current key moves from
  53. one indexed field to another. When you have a subsidiary key selected as the
  54. current key it works just like the primary key as regards browsing,
  55. searching and printing. 
  56.  
  57. There is nothing to stop you indexing one field whilst a subsidiary index
  58. based on another field is the currently-active one, thus producing what
  59. amounts to a sort within a sort.
  60.  
  61. One button which was shaded when creating the primary key is the option
  62. switch Omit null keys. Although null primary keys aren’t allowed null
  63. subsidiary keys are and the default setting for this switch is therefore
  64. OFF.  The field being indexed might in some cases be null most of the time
  65. and you want to index only the records in which it isn’t.  If so, select the
  66. switch before clicking Create.  
  67.  
  68. The Index entry on the main menu leads to a submenu offering three choices. 
  69. Show details (Ctrl K) displays the structure of the currently active key. 
  70. Show files (Ctrl I) opens the Indices directory. Delete allows you to remove
  71. an index (after confirmation).  The index file isn't actually deleted from
  72. Indices but simply renamed so that it has the prefix “Del_”.  Such an index
  73. is no longer active and will not be loaded when the database is opened. You
  74. can, however, restore it by removing the prefix but it is only useful to do
  75. so if no records have been added to or removed from the database in the
  76. meantime.
  77.  
  78. 7.2     Automatic saving of indices
  79. -----------------------------------
  80. Indices are written to disc when you close a database or quit Powerbase but,
  81. as long as the database remains open, they are in memory and therefore could
  82. be lost if the power fails or the computer is switched off.  Occasional use
  83. of the keypad’s Force update button ensures that the disc copy of all
  84. indices is more or less up-to-date but you can automate the process if you
  85. wish. Choose Preferences from the iconbar menu, make the appropriate
  86. selection from the Save indices section of the Preferences window and click
  87. on Accept. You may make Powerbase save the indices at regular intervals or
  88. simply warn you to do so.
  89.  
  90.                                 - 43 -